/**
 * 把originalObject属性及值复制给targetObject
 * @param {*} originalObject 原始对象 
 * @param {*} type 类型
 */
export const copyObject = (originalObject,type=1) =>{
    let targetObject = {}
    if(type ==1 || type ==2){
        for (const key in originalObject) {
            if(type ==1){ // 目标属性的首字母需要小写
                targetObject[transFirstLetterToLLower(key)] = originalObject[key] 
            }else{ // 完全复制
                targetObject[key] = originalObject[key]
            }
        }
    }else if(type == 3){ // 只复制targetObject的属性对应的值
        for (const key in targetObject) {
            if(originalObject[key]){
                targetObject[key] = originalObject[key]
            }
        }
    }
    return targetObject  // 返回目标属性
}

/**
 * 把字符串首字母转化为小写
 * @param {*} str 
 * @returns 
 */
const transFirstLetterToLLower = (str)=>{
    if(!str) return str
    return str.charAt(0).toLowerCase() + str.slice(1)
}